package com.chenfan.gateway.state;

/**
 * @author weishili
 */
public enum GatewayState {

    UNAUTHORIZED(30001, "用户登录失效"),
    UN_AUTH(30002, "没有此操作权限，请联系系统管理员"),
    UN_URL(503, "请求链接不存在"),
    UN_REQUEST_REJECT(503, "请求被拒绝"),
    ;

    private Integer code;
    private String message;

    GatewayState(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public static String getMsgByCode(Integer code) {
        for (GatewayState state : GatewayState.values()) {
            if (state.code.equals(code)) {
                return state.message;
            }
        }
        return null;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
